package cn.aws360.boot.base.starter.config;

import cn.aws360.boot.base.api.exception.handler.GlobalExceptionHandler;
import cn.aws360.boot.base.api.pojo.properties.AppProperties;
import cn.aws360.boot.base.api.pojo.properties.CorsProperties;
import cn.aws360.boot.base.api.pojo.properties.DocsProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author junnan
 */
@Configuration
public class BaseAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(AppProperties.class)
    public AppProperties appProperties() {
        return new AppProperties();
    }

    @Bean
    @ConditionalOnMissingBean(CorsProperties.class)
    public CorsProperties corsProperties() {
        return new CorsProperties();
    }

    @Bean
    @ConditionalOnMissingBean(DocsProperties.class)
    public DocsProperties docsProperties() {
        return new DocsProperties();
    }

    @Bean
    @ConditionalOnMissingBean(GlobalExceptionHandler.class)
    public GlobalExceptionHandler globalExceptionHandler() {
        return new GlobalExceptionHandler();
    }

}
